import 'package:HealthU/ViewModel/LoginViewModel.dart';
import 'package:flutter/material.dart';
import 'business/Tabbar/Index.dart';
import 'business/Login/LoginPage.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';


class AuthModel extends ChangeNotifier {
  bool _isLogined = false;

  bool get isLogined => _isLogined;

  void login() {
    // 执行登录逻辑，成功后设置_isLogined为true
    _isLogined = true;
    notifyListeners();
  }

  void logout() {
    // 执行登出逻辑，设置_isLogined为false
    _isLogined = false;
    notifyListeners();
  }
}

void main() {


  runApp(ProviderScope(child: MyApp()));


}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body:Consumer(
          builder: (context,ref,child){

            final viewModel = ref.watch(loginViewModelProvider);

            return viewModel.isLoggedIn ? Index() : LoginPage();


            }

        ),
      ),
    );
  }
}

